#include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> PII;

const int N = 1000;
int a[N][N], d[N][N];
bool st[N][N];
int n;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

void bfs()
{
	queue<PII> q;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(a[i][j] == 1)
			{
				q.push({i, j});
				d[i][j] = 0;
			}
		}
	}
	while(q.size())
	{
		auto t = q.front(); q.pop();
		int i = t.first, j = t.second;
		for(int  k = 0; k < 4; k++)
		{
			int x = i + dx[k];
			int y = j + dy[k];
			if(x >= 1 && y >= 1 && x <= n && y <= n && d[x][y] == 0 && a[x][y] == 1)
			{
				d[x][y] = d[i][j] + 1;			
				q.push({x, y});
			}
		}
	}
}

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int x, y;
		cin >> x >> y;
		a[x][y] = 1;
	}
	bfs();
	int ret = 0x3f3f3f3f;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(a[i][j] == 1)
			{
			for(int  k = 0; k < 4; k++)
		{
			int x = i + dx[k];
			int y = j + dy[k];
			if(x >= 1 && y >= 1 && x <= n && y <= n && d[x][y] == 0 && a[x][y] == 1)
			{
				d[x][y] = d[i][j] + 1;			
				q.push({x, y});
			}
		}
			}
			
		}
	}
	printf("%.4lf\n", ret);
	return 0;
}
